#include "StdAfx.h"
#include "solarthermal.h"

IMPLEMENT_DUICONTROL(CSolarThermalWndUI)

void SolarThermalFramWnd::Init() {
	/// solar_tower
	m_pSolarTower = static_cast<CGifControlUI *>(m_pm->FindControl(_T("cs_tower")));
	//if (m_pSolarTower) {
	//	m_pSolarTower->SetAnimationImages(vecAnimaImg_SolarTower);
	//}
	m_pPipeSolarIn = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("pipe_solar_in")));
	m_pPipeSolarIn->InitLink(m_pm);
	m_pPipeSolarOut = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("pipe_solar_out")));
	m_pPipeSolarOut->InitLink(m_pm);
	m_pPipeSolarLeftIn = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("pipe_solar_leftin")));
	m_pPipeSolarLeftIn->InitLink(m_pm);
	m_pPipeSolarRightOut = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("pipe_solar_rightout")));
	m_pPipeSolarRightOut->InitLink(m_pm);

	/// hot_pump
	m_pHotPump = static_cast<CRotButtonUI *>(m_pm->FindControl(_T("hot_pump")));
	m_pPipeHotPumpIn = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("saltpipe_hotpump_in")));
	m_pPipeHotPumpIn->InitLink(m_pm);
	m_pPipeHotPumpOut = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("saltpipe_hotpump_out")));
	m_pPipeHotPumpOut->InitLink(m_pm);

	/// cold_pump
	m_pColdPump = static_cast<CRotButtonUI *>(m_pm->FindControl(_T("cold_pump")));
	m_pPipeColdPumpIn = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("saltpipe_coldpump_in")));
	m_pPipeColdPumpIn->InitLink(m_pm);
	m_pPipeColdPumpOut = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("saltpipe_coldpump_out")));
	m_pPipeColdPumpOut->InitLink(m_pm);

	/// hot_pump_2repo
	m_pHotPump2Repo = static_cast<CRotButtonUI *>(m_pm->FindControl(_T("hot_pump_2repo")));
	m_pPipeHotPump2RepoIn = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("saltpipe_hotpump_2repo_in")));
	m_pPipeHotPump2RepoIn->InitLink(m_pm);
	m_pPipeHotPump2RepoOut = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("saltpipe_hotpump_2repo_out")));
	m_pPipeHotPump2RepoOut->InitLink(m_pm);

	/// water_pump
	m_pWaterPump = static_cast<CRotButtonUI *>(m_pm->FindControl(_T("waterpump")));
	m_pWaterPumpDown = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("waterpipe_waterpump_down")));
	m_pWaterPumpDown->InitLink(m_pm);
	m_pWaterPumpUp = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("waterpipe_waterpump_up")));
	m_pWaterPumpUp->InitLink(m_pm);
	m_pWaterPumpIn = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("waterpipe_waterpump_in")));
	m_pWaterPumpIn->InitLink(m_pm);
	m_pWaterPumpOut = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("waterpipe_waterpump_out")));
	m_pWaterPumpOut->InitLink(m_pm);

	/// coldsalt_repo
	m_pColdRepo = static_cast<CSTTankUI *>(m_pm->FindControl(_T("coldsalt_repo")));
	//if (m_pColdRepo) {
	//	m_pColdRepo->SetAnimationImages(vecAnimaImg);
	//}
	m_pColdRepoIn = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("saltpipe_coldsaltrepo_in")));
	m_pColdRepoIn->InitLink(m_pm);
	m_pColdRepoOut = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("saltpipe_coldsaltrepo_out")));
	m_pColdRepoOut->InitLink(m_pm);
	m_pColdSaltLoop = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("saltpipe_left")));
	m_pColdSaltLoop->InitLink(m_pm);

	/// hotsalt_repo
	m_pHotRepo = static_cast<CSTTankUI *>(m_pm->FindControl(_T("hotsalt_repo")));
	//if (m_pHotRepo) {
	//	m_pHotRepo->SetAnimationImages(vecAnimaImg);
	//}
	m_pHotRepoIn = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("saltpipe_hotsaltrepo_in")));
	m_pHotRepoIn->InitLink(m_pm);
	m_pHotRepoOut = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("saltpipe_hotsaltrepo_out")));
	m_pHotRepoOut->InitLink(m_pm);

	/// steam_gener
	m_pSteamGener = static_cast<CGifControlUI *>(m_pm->FindControl(_T("steam_gener")));
	//if (m_pSteamGener) {
	//	m_pSteamGener->SetAnimationImages(vecAnimaImg);
	//}
	m_pSteamGenSaltIn = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("saltpipe_steamgen_hot_in")));
	m_pSteamGenSaltIn->InitLink(m_pm);
	m_pSteamGenSaltOut = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("saltpipe_steamgen_cold_out")));
	m_pSteamGenSaltOut->InitLink(m_pm);
	m_pSteamGenWaterIn = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("waterpipe_steamgen_in")));
	m_pSteamGenWaterIn->InitLink(m_pm);
	m_pSteamGenSteamOut = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("steampipe_steamgen_out")));
	m_pSteamGenSteamOut->InitLink(m_pm);

	/// dynamo
	m_pDynamo = static_cast<CGifControlUI *>(m_pm->FindControl(_T("dynamo")));
	//if (m_pDynamo) {
	//	m_pDynamo->SetAnimationImages(vecAnimaImg);
	//}
	m_pDynamoSteamIn = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("steampipe_dynamo_in")));
	m_pDynamoSteamIn->InitLink(m_pm);
	m_pDynamoWaterOut = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("steampipe_dynamo_out")));
	m_pDynamoWaterOut->InitLink(m_pm);
	m_pElectricOut = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("electric_dynamo_out")));
	m_pElectricOut->InitLink(m_pm);

	/// condenser
	m_pCondenser = static_cast<CGifControlUI *>(m_pm->FindControl(_T("condenser")));
	//if (m_pCondenser) {
	//	m_pCondenser->SetAnimationImages(vecAnimaImg);
	//}
	m_pCondenserSteamIn = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("steampipe_condenser_in")));
	m_pCondenserSteamIn->InitLink(m_pm);
	m_pCondenserWaterOut = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("waterpipe_condenser_out")));
	m_pCondenserWaterOut->InitLink(m_pm);

	/// deaerator
	m_pDeaerator = static_cast<CGifControlUI *>(m_pm->FindControl(_T("deaerator")));
	m_pDeaeratorWaterIn = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("waterpipe_deaerator_in")));
	m_pDeaeratorWaterIn->InitLink(m_pm);
	m_pDeaeratorWaterout = static_cast<CLineFlowButtonUI *>(m_pm->FindControl(_T("waterpipe_deaerator_out")));
	m_pDeaeratorWaterout->InitLink(m_pm);

	/// ac_out
	m_pAcNet = static_cast<CGifControlUI *>(m_pm->FindControl(_T("ac_out")));
	//m_pAcNet->SetAnimationImages(vecAnimaImg);

	/// to act:
	m_pToAct = static_cast<CButtonUI *>(m_pm->FindControl(_T("to_act")));
	m_pToPause = static_cast<CButtonUI *>(m_pm->FindControl(_T("to_m_act")));
	m_pToStop = static_cast<CButtonUI *>(m_pm->FindControl(_T("to_stop")));

	/// to init flow vector
	InitSaltFlow();
	InitSteamFlow();
	InitElectricityFlow();

	InitCodeSaltTankToHeatFlow();
	InitCodeSaltPumptoCSTFlow();
	InitHotSaltPumptoTankFlow();
	InitHotSaltPumptoSteamGenFlow();
	InitUseSteamToDynamoFlow();
	InitLoopTheSteamFlow();

	/// to init flow chain
	//InitFlowChain();

	/// to init energy flow manager
	m_pToShow = static_cast<CGifControlUI *>(m_pm->FindControl(_T("to_show")));
	EnergyFlowManage::GetEnergyFlowManager()->AddReceiver(m_pToShow);

	/// auto select dpi
	INT cx = ::GetSystemMetrics(SM_CXSCREEN);
	if (cx > 1440)
	{
		m_pm->SetDPI(144);
	}
	else if (cx >= 1280 && cx < 1440)
	{
		m_pm->SetDPI(120);
	}
	else
	{
		m_pm->SetDPI(96);
	}
}

void SolarThermalFramWnd::InitSaltFlow()
{
	if (vecSaltFlowLoop.size() != 0)
	{
		return;
	}

	vecSaltFlowLoop.push_back(m_pColdRepo);
	vecSaltFlowLoop.push_back(m_pColdPump);

	vecSaltFlowLoop.push_back(m_pColdRepoOut);
	vecSaltFlowLoop.push_back(m_pPipeColdPumpIn);

	vecSaltFlowLoop.push_back(m_pPipeColdPumpOut);
	vecSaltFlowLoop.push_back(m_pPipeSolarIn);
	vecSaltFlowLoop.push_back(m_pPipeSolarLeftIn);

	vecSaltFlowLoop.push_back(m_pSolarTower);

	vecSaltFlowLoop.push_back(m_pHotPump2Repo);
	vecSaltFlowLoop.push_back(m_pPipeSolarRightOut);
	vecSaltFlowLoop.push_back(m_pPipeSolarOut);

	vecSaltFlowLoop.push_back(m_pPipeHotPump2RepoIn);
	vecSaltFlowLoop.push_back(m_pPipeHotPump2RepoOut);

	vecSaltFlowLoop.push_back(m_pHotRepoIn);

	vecSaltFlowLoop.push_back(m_pHotRepo);
	vecSaltFlowLoop.push_back(m_pHotPump);

	vecSaltFlowLoop.push_back(m_pHotRepoOut);
	vecSaltFlowLoop.push_back(m_pPipeHotPumpIn);

	vecSaltFlowLoop.push_back(m_pPipeHotPumpOut);
	vecSaltFlowLoop.push_back(m_pSteamGenSaltIn);

	vecSaltFlowLoop.push_back(m_pSteamGener);

	vecSaltFlowLoop.push_back(m_pSteamGenSaltOut);
	vecSaltFlowLoop.push_back(m_pColdSaltLoop);
	vecSaltFlowLoop.push_back(m_pColdRepoIn);
}

void SolarThermalFramWnd::InitSteamFlow()
{
	if (vecSteamFlowLoop.size() != 0)
	{
		return;
	}

	vecSteamFlowLoop.push_back(m_pSteamGener);

	vecSteamFlowLoop.push_back(m_pSteamGenSteamOut);
	vecSteamFlowLoop.push_back(m_pDynamoSteamIn);

	vecSteamFlowLoop.push_back(m_pDynamo);

	vecSteamFlowLoop.push_back(m_pDynamoWaterOut);
	vecSteamFlowLoop.push_back(m_pCondenserSteamIn);

	vecSteamFlowLoop.push_back(m_pCondenser);
	vecSteamFlowLoop.push_back(m_pCondenserWaterOut);

	vecSteamFlowLoop.push_back(m_pDeaeratorWaterIn);
	vecSteamFlowLoop.push_back(m_pDeaerator);

	vecSteamFlowLoop.push_back(m_pWaterPump);
	vecSteamFlowLoop.push_back(m_pDeaeratorWaterout);
	
	vecSteamFlowLoop.push_back(m_pWaterPumpUp);
	vecSteamFlowLoop.push_back(m_pWaterPumpIn);

	vecSteamFlowLoop.push_back(m_pWaterPumpOut);
	vecSteamFlowLoop.push_back(m_pWaterPumpDown);
	vecSteamFlowLoop.push_back(m_pSteamGenWaterIn);
}

void SolarThermalFramWnd::InitElectricityFlow()
{
	if (vecElectricityFlowLoop.size() != 0)
	{
		return;
	}

	vecElectricityFlowLoop.push_back(m_pDynamo);
	vecElectricityFlowLoop.push_back(m_pElectricOut);
	vecElectricityFlowLoop.push_back(m_pAcNet);
}

void SolarThermalFramWnd::InitFlowChain()
{
	if (m_bIsAutoFlowInit)
	{
		return;
	}

	/// to init flow vector
	SolarThermalShow *next = NULL;
	for (vector<SolarThermalShow *>::iterator iter = vecSaltFlowLoop.begin(); iter != vecSaltFlowLoop.end(); iter++)
	{
		if (iter + 1 != vecSaltFlowLoop.end())
		{
			next = *(iter + 1);
			if (next)
			{
				(*iter)->SetNextAnimPlayer(next);
			}
		}
	}
	for (vector<SolarThermalShow *>::iterator iter = vecSteamFlowLoop.begin(); iter != vecSteamFlowLoop.end(); iter++)
	{
		if (iter + 1 != vecSteamFlowLoop.end())
		{
			next = *(iter + 1);
			if (next)
			{
				(*iter)->SetNextAnimPlayer(next);
			}
		}
	}
	for (vector<SolarThermalShow *>::iterator iter = vecElectricityFlowLoop.begin(); iter != vecElectricityFlowLoop.end(); iter++)
	{
		if (iter + 1 != vecElectricityFlowLoop.end())
		{
			next = *(iter + 1);
			if (next)
			{
				(*iter)->SetNextAnimPlayer(next);
			}
		}
	}

	m_bIsAutoFlowInit = TRUE;
}

void SolarThermalFramWnd::ActSaltFlow()
{
	(*vecSaltFlowLoop.begin())->ToActFlowAnim();
}
void SolarThermalFramWnd::ActSteamFlow()
{
	(*vecSteamFlowLoop.begin())->ToActFlowAnim();
}
void SolarThermalFramWnd::ActElectricityFlow()
{
	(*vecElectricityFlowLoop.begin())->ToActFlowAnim();
}

/// --------------------------------------------------
void SolarThermalFramWnd::InitCodeSaltTankToHeatFlow()
{
	if (vecCodeSaltTankToHeat.size() != 0)
	{
		return;
	}

	vecCodeSaltTankToHeat.push_back(m_pColdRepo);
}

void SolarThermalFramWnd::InitCodeSaltPumptoCSTFlow()
{
	if (vecCodeSaltPumptoCST.size() != 0)
	{
		return;
	}

	vecCodeSaltPumptoCST.push_back(m_pColdPump);
	vecCodeSaltPumptoCST.push_back(m_pColdRepoOut);
	vecCodeSaltPumptoCST.push_back(m_pPipeColdPumpIn);
	vecCodeSaltPumptoCST.push_back(m_pPipeColdPumpOut);
	vecCodeSaltPumptoCST.push_back(m_pPipeSolarIn);
	vecCodeSaltPumptoCST.push_back(m_pPipeSolarLeftIn);
	vecCodeSaltPumptoCST.push_back(m_pSolarTower);
}

void SolarThermalFramWnd::InitHotSaltPumptoTankFlow()
{
	if (vecHotSaltPumptoTank.size() != 0)
	{
		return;
	}

	vecHotSaltPumptoTank.push_back(m_pPipeSolarRightOut);
	vecHotSaltPumptoTank.push_back(m_pPipeSolarOut);

	vecHotSaltPumptoTank.push_back(m_pHotPump2Repo);
	vecHotSaltPumptoTank.push_back(m_pPipeHotPump2RepoIn);
	vecHotSaltPumptoTank.push_back(m_pPipeHotPump2RepoOut);

	vecHotSaltPumptoTank.push_back(m_pHotRepoIn);
	vecHotSaltPumptoTank.push_back(m_pHotRepo);
}

void SolarThermalFramWnd::InitHotSaltPumptoSteamGenFlow()
{
	if (vecHotSaltPumptoSteamGen.size() != 0)
	{
		return;
	}

	vecHotSaltPumptoSteamGen.push_back(m_pHotPump);
	vecHotSaltPumptoSteamGen.push_back(m_pHotRepoOut);
	vecHotSaltPumptoSteamGen.push_back(m_pPipeHotPumpIn);
	vecHotSaltPumptoSteamGen.push_back(m_pPipeHotPumpOut);
	vecHotSaltPumptoSteamGen.push_back(m_pSteamGenSaltIn);
	vecHotSaltPumptoSteamGen.push_back(m_pSteamGener);
	vecHotSaltPumptoSteamGen.push_back(m_pSteamGenSaltOut);
	vecHotSaltPumptoSteamGen.push_back(m_pColdSaltLoop);
	vecHotSaltPumptoSteamGen.push_back(m_pColdRepoIn);
}

void SolarThermalFramWnd::InitUseSteamToDynamoFlow()
{
	if (vecUseSteamToDynamo.size() != 0)
	{
		return;
	}

	vecUseSteamToDynamo.push_back(m_pSteamGener);
	vecUseSteamToDynamo.push_back(m_pSteamGenSteamOut);
	vecUseSteamToDynamo.push_back(m_pDynamoSteamIn);
	vecUseSteamToDynamo.push_back(m_pDynamo);
	vecUseSteamToDynamo.push_back(m_pDynamoWaterOut);
	vecUseSteamToDynamo.push_back(m_pCondenserSteamIn);
	vecUseSteamToDynamo.push_back(m_pCondenser);
	vecUseSteamToDynamo.push_back(m_pCondenserWaterOut);
	vecUseSteamToDynamo.push_back(m_pDeaeratorWaterIn);
	vecUseSteamToDynamo.push_back(m_pDeaerator);
	
}

void SolarThermalFramWnd::InitLoopTheSteamFlow()
{
	if (vecLoopTheSteam.size() != 0)
	{
		return;
	}

	vecLoopTheSteam.push_back(m_pWaterPump);
	vecLoopTheSteam.push_back(m_pDeaeratorWaterout);
	vecLoopTheSteam.push_back(m_pWaterPumpUp);
	vecLoopTheSteam.push_back(m_pWaterPumpIn);
	vecLoopTheSteam.push_back(m_pWaterPumpOut);
	vecLoopTheSteam.push_back(m_pWaterPumpDown);
	vecLoopTheSteam.push_back(m_pSteamGenWaterIn);
}

void SolarThermalFramWnd::InitFlowManualAnimChain()
{
	if (m_bIsManualFlowInit)
	{
		return;
	}

	SolarThermalShow *next = NULL;
	for (vector<SolarThermalShow *>::iterator iter = vecCodeSaltTankToHeat.begin(); iter != vecCodeSaltTankToHeat.end(); iter++)
	{
		if (iter + 1 != vecCodeSaltTankToHeat.end())
		{
			next = *(iter + 1);
			if (next)
			{
				(*iter)->SetNextAnimPlayer(next);
			}
		}
	}
	for (vector<SolarThermalShow *>::iterator iter = vecCodeSaltPumptoCST.begin(); iter != vecCodeSaltPumptoCST.end(); iter++)
	{
		if (iter + 1 != vecCodeSaltPumptoCST.end())
		{
			next = *(iter + 1);
			if (next)
			{
				(*iter)->SetNextAnimPlayer(next);
			}
		}
	}
	for (vector<SolarThermalShow *>::iterator iter = vecHotSaltPumptoTank.begin(); iter != vecHotSaltPumptoTank.end(); iter++)
	{
		if (iter + 1 != vecHotSaltPumptoTank.end())
		{
			next = *(iter + 1);
			if (next)
			{
				(*iter)->SetNextAnimPlayer(next);
			}
		}
	}
	for (vector<SolarThermalShow *>::iterator iter = vecHotSaltPumptoSteamGen.begin(); iter != vecHotSaltPumptoSteamGen.end(); iter++)
	{
		if (iter + 1 != vecHotSaltPumptoSteamGen.end())
		{
			next = *(iter + 1);
			if (next)
			{
				(*iter)->SetNextAnimPlayer(next);
			}
		}
	}
	for (vector<SolarThermalShow *>::iterator iter = vecUseSteamToDynamo.begin(); iter != vecUseSteamToDynamo.end(); iter++)
	{
		if (iter + 1 != vecUseSteamToDynamo.end())
		{
			next = *(iter + 1);
			if (next)
			{
				(*iter)->SetNextAnimPlayer(next);
			}
		}
	}
	for (vector<SolarThermalShow *>::iterator iter = vecLoopTheSteam.begin(); iter != vecLoopTheSteam.end(); iter++)
	{
		if (iter + 1 != vecLoopTheSteam.end())
		{
			next = *(iter + 1);
			if (next)
			{
				(*iter)->SetNextAnimPlayer(next);
			}
		}
	}
	for (vector<SolarThermalShow *>::iterator iter = vecElectricityFlowLoop.begin(); iter != vecElectricityFlowLoop.end(); iter++)
	{
		if (iter + 1 != vecElectricityFlowLoop.end())
		{
			next = *(iter + 1);
			if (next)
			{
				(*iter)->SetNextAnimPlayer(next);
			}
		}
	}

	m_bIsManualFlowInit = TRUE;
}

void SolarThermalFramWnd::ActCodeSaltTankToHeatFlow() { (*vecCodeSaltTankToHeat.begin())->ToActFlowAnim(); }
void SolarThermalFramWnd::ActCodeSaltPumptoCSTFlow() { (*vecCodeSaltPumptoCST.begin())->ToActFlowAnim(); }
void SolarThermalFramWnd::ActHotSaltPumptoTankFlow() { (*vecHotSaltPumptoTank.begin())->ToActFlowAnim(); }
void SolarThermalFramWnd::ActHotSaltPumptoSteamGenFlow() { (*vecHotSaltPumptoSteamGen.begin())->ToActFlowAnim(); }
void SolarThermalFramWnd::ActUseSteamToDynamoFlow() { (*vecUseSteamToDynamo.begin())->ToActFlowAnim(); }
void SolarThermalFramWnd::ActLoopTheSteamFlow() { (*vecLoopTheSteam.begin())->ToActFlowAnim(); }

/// --------------------------------------------------

void SolarThermalFramWnd::StartFlow()
{
	m_enShowMode = SHOW_MODE_AUTO;
	InitFlowChain();
	m_pToShow->SetVisible(false);
	ActSaltFlow();
}

void SolarThermalFramWnd::ManualFlow()
{
	m_enShowMode = SHOW_MODE_MANUAL;
	InitFlowManualAnimChain();
	m_pToShow->SetVisible(false);
	ActCodeSaltTankToHeatFlow();
}

void SolarThermalFramWnd::StopFlow()
{
	// for (vector<SolarThermalShow *>::iterator iter = vecSaltFlowLoop.begin(); iter != vecSaltFlowLoop.end(); iter++)
	// {
	// 	(*iter)->ToStopFlowAnim();
	// }
	// for (vector<SolarThermalShow *>::iterator iter = vecSteamFlowLoop.begin(); iter != vecSteamFlowLoop.end(); iter++)
	// {
	// 	(*iter)->ToStopFlowAnim();
	// }
	// for (vector<SolarThermalShow *>::iterator iter = vecElectricityFlowLoop.begin(); iter != vecElectricityFlowLoop.end(); iter++)
	// {
	// 	(*iter)->ToStopFlowAnim();
	// }

	for (vector<SolarThermalShow *>::iterator iter = vecSaltFlowLoop.begin(); iter != vecSaltFlowLoop.end(); iter++)
	{
		(*iter)->ToResetFlowAnim();
	}
	for (vector<SolarThermalShow *>::iterator iter = vecSteamFlowLoop.begin(); iter != vecSteamFlowLoop.end(); iter++)
	{
		(*iter)->ToResetFlowAnim();
	}
	for (vector<SolarThermalShow *>::iterator iter = vecElectricityFlowLoop.begin(); iter != vecElectricityFlowLoop.end(); iter++)
	{
		(*iter)->ToResetFlowAnim();
	}

	m_bIsManualFlowInit = FALSE;
	m_bIsAutoFlowInit = FALSE;

	m_pToShow->SetVisible(false);
}

BOOL SolarThermalFramWnd::OnLClick(CControlUI *pControl) {
	BOOL	bOK = FALSE;
	CDuiString sName = pControl->GetName();
	if (sName.CompareNoCase(_T("to_act")) == 0)
	{
		StartFlow();
		bOK = TRUE;
	}
	else if (sName.CompareNoCase(_T("to_m_act")) == 0)
	{
		ManualFlow();
		bOK = TRUE;
	}
	else if (sName.CompareNoCase(_T("to_stop")) == 0)
	{
		StopFlow();
		bOK = TRUE;
	}
	///------------------------------------------------
	else if (sName.CompareNoCase(_T("coldsalt_repo")) == 0)
	{
		if (m_enShowMode == SHOW_MODE_MANUAL)
		{
			ActCodeSaltTankToHeatFlow();
		}
		bOK = TRUE;
	}
	else if (sName.CompareNoCase(_T("cold_pump")) == 0)
	{
		if (m_enShowMode == SHOW_MODE_MANUAL)
		{
			ActCodeSaltPumptoCSTFlow();
		}
		bOK = TRUE;
	}
	else if (sName.CompareNoCase(_T("hot_pump_2repo")) == 0)
	{
		if (m_enShowMode == SHOW_MODE_MANUAL)
		{
			ActHotSaltPumptoTankFlow();
		}
		bOK = TRUE;
	}
	else if (sName.CompareNoCase(_T("hot_pump")) == 0)
	{
		if (m_enShowMode == SHOW_MODE_MANUAL)
		{
			ActHotSaltPumptoSteamGenFlow();
		}
		bOK = TRUE;
	}
	else if (sName.CompareNoCase(_T("dynamo")) == 0)
	{
		if (m_enShowMode == SHOW_MODE_MANUAL)
		{
			ActUseSteamToDynamoFlow();
		}
		bOK = TRUE;
	}
	else if (sName.CompareNoCase(_T("waterpump")) == 0)
	{
		if (m_enShowMode == SHOW_MODE_MANUAL)
		{
			ActLoopTheSteamFlow();
		}
		bOK = TRUE;
	}

	return bOK;
	///------------------------------------------------
}
